<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/13
 * Time: 23:11
 */
namespace app\api\controller;
use app\common\controller\BaseApi;
use app\common\model\GameInfo;
use app\common\model\HomePic;
use function Couchbase\defaultDecoder;

class Index extends BaseApi
{
    //获取游戏列表
    public function getRows(){
       return $this->commonData(1,GameInfo::instance()->doPage()->alias('g')
           ->join('enterprise e','e.id=g.provideid')->join('game_sort gs','g.sort = gs.id')->field('g.game_name,g.game_brief,g.size,g.discount,g.id,e.enterprise_name,gs.sort_name
')->select());
    }
    //根据游戏id获取游戏详情
    public  function  getDetail()
    {
        return $this->commonData(1,GameInfo::instance()->where(['g.id'=>I('id',1,'intval')])->alias('g')
            ->join('enterprise e','e.id=g.provideid')->join('game_sort gs','g.sort = gs.id')->field('g.*,e.enterprise_name,gs.sort_name
')->select());
    }

    //下载次数叠加
    public function  addDownloadTimes()
    {
        GameInfo::instance()->where(['id'=>I('id',0,'intval')])->setInc('',1);
        return true;
    }

    //获取首页图片列表
    public  function  getPicRows()
    {
        return $this->commonData(1,HomePic::instance()->alias('g')->field('g.*')->select());
    }
}